#ifndef MINIATM_H
#define MINIATM_H

#include "ImamMenu.h"

typedef struct
{
	int RecordNo;  //always inc until MAX_RECNO
	int Status; //0=unprocessed, unapproved
				//1=Reversal needed
				//2=Transaction Approved and Complete
				//3=Reversal of void needed 
				//4=void approved
	int inCode;
	int inOriginalCode;
	int inMenuIndex;
	int inManual;
	int STAN;
	int VoidSTAN;
    char szDate[DATE_SIZE + 1];	//MMDDYY  ==> YYMMDD
    char szTime[TIME_SIZE + 1];	//HHMMSS
	char szTotal[20];
	long Amt;
	long Tip;
	long Total;
	long Point;
	long Balance;
	long lnVoucherAmt;
	int inAccType;			//Saving=2 or Current=3
	unsigned long lnInvNum;
	int isOnUs;

	char szRetRefNum[RET_REF_SIZE + 1];
	char szAuthCode[AUTH_CODE_SIZE + 1];          /* Auth Code           */
	char szRespCode[RESP_CODE_SIZE + 1];
    char szPAN[PAN_SIZE + 1];                     /* Account number */
    char szExpDate[EXP_DATE_SIZE + 1];            /* Expiration date */
    char szCHolder[CHOLDER_SIZE + 1];               /*  Card holder name */
	char szPIN[PIN_SIZE + 1];                           /* Pin data            */
    char szKSN[KSN_SIZE + 1];                           /* Authentication Key  */
	char szPIN2[PIN_SIZE + 1];                           /* Pin 2 data            */
	int EntryMode;  //0
	char stT2Data[TRACK2_SIZE +1];
	char szAdditionalInfo[22];
	char szInputNumber_1[22];  
	char szInputNumber_2[22];  
	char szInputNumber_3[22]; 
	char stT2DataImam[TRACK2_SIZE +1];

	char szVoucherSN[19];
	char szF48[300];
	char szF54[30];
	char szF63[22];
	int  inReceiptCopy;  //1=merchant copy, 2=bank, 3=Cust Copy, 4=duplicate 
	SMenu TrxMenu;
} IMAM_TRANSACTION_OBJECT;


typedef struct {
	//int inCode;
	//int inManual;
	//char szCode[22];
	char szMsgID[5];
	char szProcCode[7];
	unsigned char bitmap[33];
} TRANSACTION_BITMAP;

#define TRX_MANUAL		"TRX.MANUAL"
#define HOST_CARD_ONUS  "HOST.CARD.ONUS"
#define TXR_OFFUS		"TRX.OFFUS"
#define FEE				"FEE"
#define POWERSAVE		"POWERSAVE"
#define F48_ADD_SIZE  30  //add to cover changing reply message suggested by Mr. Toro about inst name
#define IMAM_INV_NUM		"INVNUM"
#define IMAM_STAN_NUM		"STANNUM"

#define TRX_AUTO_REVERSAL	"TRX.AUTOREVERSAL"
#define PRT_COPY			"PRT.COPY"

#define CENTERED  0
#define L_TEXT    1
#define R_TEXT    2

#define MSG_BUFF_SIZE			1028

#define BATCH_SIZE				200L //must be convert to long 'L'
#define MAX_RECNO				(2*BATCH_SIZE)  //be carefull not melebihi 32000
//and must be at least 2*BATCH_SIZE to get ball rolling
#define IMAM_EMA_BATCH			"EmaBatch"

int inMiniAtmTransactionInit(TRANSACTION_OBJECT *pobTran);
int inPmtTrxPurchase(TRANSACTION_OBJECT *pobTran);
int inPmtTrxTransfer(TRANSACTION_OBJECT *pobTran);
int inPmtTrxInfoSaldo(TRANSACTION_OBJECT *pobTran);
int inPmtTrxMiniStatement(TRANSACTION_OBJECT *pobTran);
int inPmtTrxInfoCreditCard(TRANSACTION_OBJECT *pobTran);
int inPmtTrxIsiUlang(TRANSACTION_OBJECT *pobTran);
int inPmtTrxBillPayment(TRANSACTION_OBJECT *pobTran);
int inPmtTrxNoBillPayment(TRANSACTION_OBJECT *pobTran);
int inPmtTrxRegistrasi(TRANSACTION_OBJECT *pobTran);
int inPmtTrxPinChange(TRANSACTION_OBJECT *pobTran);
int inPmtTrxTin(TRANSACTION_OBJECT *pobTran);
int inPmtTrxBelanjaPoin(TRANSACTION_OBJECT *pobTran);

int inImamSendReversal(TRANSACTION_OBJECT *pobTran);
int inImamReprintLast(TRANSACTION_OBJECT *pobTran);
int inImamReprintAny(TRANSACTION_OBJECT *pobTran);
int inImamSummaryReport(TRANSACTION_OBJECT *pobTran);
int inImamDetailReport(TRANSACTION_OBJECT *pobTran);
int inImamPastSummaryReport(TRANSACTION_OBJECT *pobTran);
int inImamPastDetailReport(TRANSACTION_OBJECT *pobTran);
int inImamPowerOff(TRANSACTION_OBJECT *pobTran);
int inImamClearReversal(TRANSACTION_OBJECT *pobTran);
int inImamClearBatch(TRANSACTION_OBJECT *pobTran);

int inShowTitle(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inGetCard(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inGetCardInside(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inGetCardManual(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inCheckCard(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamGetAmount(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg);
int inImamGetAmountForBillPayment(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg);
int inGetGeneralInputNumber_1(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg, int MinDigit, int MaxDigit);
int inGetGeneralInputNumber_2(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg, int MinDigit, int MaxDigit);
int inGetGeneralInputNumber_3(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg, int MinDigit, int MaxDigit);
int inGetVoucherAmt(IMAM_TRANSACTION_OBJECT *pobTranEma, char *Msg);

int inSelectAccount(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inShowPobTran(IMAM_TRANSACTION_OBJECT *pobTranEma);
void vdGetTrxFee(char *buffer, IMAM_TRANSACTION_OBJECT *pobTranEma);
void vdDisplayFee(IMAM_TRANSACTION_OBJECT *pobTranEma);
void vdDisplayFee2(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamGetEncryptedPin(IMAM_TRANSACTION_OBJECT *pobTranEma, char *EnterPinLabel, TRANSACTION_OBJECT *pobTran);

int inImamSetBitmap(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamPackMessage(IMAM_TRANSACTION_OBJECT *pobTranEma, unsigned char *SentBuff);
int inImamUnpackAndValidateMessage(IMAM_TRANSACTION_OBJECT *pobTranEma, unsigned char *RecvBuff);
int inImamSendAndReceiveMessage(IMAM_TRANSACTION_OBJECT *pobTranEma, unsigned char *SentBuff, unsigned char *RecvBuff, int Reversal);
int inImamFindAndSendReversal(void);
int GetReversalTransactionRecord(IMAM_TRANSACTION_OBJECT *pobTranEma);
int GetLastTransactionRecord(int Status, IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamSendAndReceiveReversal(IMAM_TRANSACTION_OBJECT *pobTranEma, unsigned char *SentBuff, unsigned char *RecvBuff);

int SaveNewBatchRecord(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamSaveBatchRecordAfterTrx(IMAM_TRANSACTION_OBJECT *pobTranEma);
int SaveBatchRecord(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamSaveBatchRecordForReversal(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamSaveBatchRecordAfterReversal(IMAM_TRANSACTION_OBJECT *pobTranEma);

int inDisplayHostResponse(IMAM_TRANSACTION_OBJECT *pobTranEma);
int	inImamDisplayResponse(IMAM_TRANSACTION_OBJECT *pobTranEma, unsigned long lnShowTime);
void vdUpdateLnTotal(IMAM_TRANSACTION_OBJECT *pobTranEma);

int	inImamPrintResponse(IMAM_TRANSACTION_OBJECT *pobTranEma);
int PrintRcpt(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintHeader(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintCardDetail(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintTransactionDetail(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintSignature(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintFooter(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inPrintShiftPaper(IMAM_TRANSACTION_OBJECT *pobTranEma);
int	RePrintResponse(IMAM_TRANSACTION_OBJECT *pobTranEma);
int inImamPrintSummaryReport(char *TheDate);
int inImamPrintDetailReport(char *TheDate);

int inBeginComm(void);
int inEndComm(void);
void vdImamFreeVariantTables(void); 
int inImamCreateVariantTables(void); 
int CreateBatchRecord(void);
int ChooseBatchRecord(unsigned long lnInv, int Status, IMAM_TRANSACTION_OBJECT *pobTranEma);
int inDisclaimer(char *szDisclaimer);
extern int inImamReleaseComm(void);
extern int inImamPrintISOPacket(VS_BOOL fSendPacket, unsigned char *pucMessage, int inLen) ;
extern int inImamPrintISOPacket(VS_BOOL fSendPacket, unsigned char *pucMessage, int inLen) ;
extern int inCPACGetMerchEnable(TRANSACTION_OBJECT* pobTran);

#endif
